package com.lagou.common.service;

import com.lagou.common.dao.OrderDao;
import com.lagou.common.pojo.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class OrderService {

    @Autowired
    private OrderDao orderDao;

    public void save(Order order) {
        orderDao.save(order);
    }

    public List<Order> findAllByStatus(String status) {
       return orderDao.findAllByStatus(status);
    }

    public List<Order> findAll() {
        return orderDao.findAll();
    }

    public Order findById(Long id) {
        Optional<Order> optional = orderDao.findById(id);

        if (optional.isEmpty()) {
            return null;
        } else {
            return optional.get();
        }

    }


}
